package com.mine.client.view;

import javax.swing.*;
import java.net.URL;

/**
 *
 * 内部类
 *
 * @author jalasmart
 * 2024/3/20 13:51
 */
public final class URLs {
    public static ImageIcon getImageIcon(String filename, String... description) {
        if (filename == null) {
            return null;
        }
        return new ImageIcon(getLocationOfImages(filename), (description != null) ? String.join(",", description) : "");
    }

    public static URL getLocationOfImages(String name) {
        return getLocationByResources(String.join("/", "images", name));
    }

    private static URL getLocationByResources(String name) {
        return URLs.class.getClassLoader().getResource(name);
    }
}
